package com.yycx.module.bus.provider.handler.haiying.settle.calculate;

import com.yycx.common.base.entity.EntityMap;
import com.yycx.common.base.utils.FlymeUtils;
import com.yycx.common.mybatis.interceptor.PageInterceptor;
import com.yycx.common.mybatis.model.PageParams;
import com.yycx.common.mybatis.query.CriteriaQuery;
import com.yycx.module.bus.client.entity.BusDept;
import com.yycx.module.bus.client.entity.hy.HyOrderDetail;
import com.yycx.module.bus.client.enums.HySaleTypeEnum;
import com.yycx.module.bus.provider.service.BusDeptService;
import com.yycx.module.bus.provider.service.BusOrderService;
import com.yycx.module.bus.provider.service.hy.HyOrderDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.List;

/**
 * 核算申请商品列表
 *
 * @author zyf
 */
@Component
public class HyCalculateOrderDetailsListHandler implements PageInterceptor<HyOrderDetail> {


    @Autowired
    private BusOrderService orderService;
    @Autowired
    private BusDeptService deptService;

    @Override
    public void prepare(CriteriaQuery<HyOrderDetail> cq, PageParams pageParams, EntityMap params) {
        PageInterceptor.super.prepare(cq, pageParams, params);
    }

    @Override
    public List<EntityMap> complete(CriteriaQuery<HyOrderDetail> cq, List<EntityMap> result, EntityMap extra) {
        for (EntityMap entityMap : result) {
            Long deptId = entityMap.getLong("deptId");
            BusDept dept = deptService.getById(deptId);
            entityMap.put("deptType", dept.getDeptType());
        }
        return result;
    }
}
